#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the version 3 of the GNU Lesser General Public License
#   as published by the Free Software Foundation.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU Lesser General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Copyright (c) NEC Deutschland GmbH, NEC HPC Europe
#
# $Id: log.py 144 2011-12-07 13:33:29Z efocht@gmail.com $


from aggmon.databases.metric.time_series_database import TimeSeriesDatabase
from basic_types import JobRecord


__all__ = ["LOG"]


class JOB(TimeSeriesDatabase):
    """
    A LOG contains the history of string valued metrics, and should just be built
    of the state changes, noCopy of log_record.pyt every measured state.
    """

    def append( self, time_ns, value, name="", host="" ):
        """
        Append a value (and output string) to the current LOG database.
        """
        self.append_record( JobRecord( time_ns, value, name=name, host=host ) )

    def filter_records( self, records ):
        """
        Filter records list. Do nothing for Job records.
        """
        return records

    def insert( self, time_ns, value, name="", host="" ):
        """
        Inserts a time, value and output string into the database.
        """
        self.insert_record( JobRecord( time_ns, value, name=name, host=host ) )

    def record( self ):
        return JobRecord()


from basic_types.factory import Factory
Factory.set_factory( "JOB", JOB, __name__ )
